# Contributor: larchunix
# Maintainer: Jelle van der Waa <jelle@archlinux.org>

pkgname=librepo
pkgver=1.15.1
pkgrel=2
pkgdesc="Repodata downloading library"
arch=('loong64' 'x86_64')
url="https://github.com/rpm-software-management/$pkgname"
license=('GPL')
depends=('curl' 'glib2' 'gpgme' 'libxml2' 'openssl')
makedepends=('cmake' 'python')
checkdepends=('check' 'python-gpgme' 'python-pyxattr' 'python-requests')
optdepends=('python: for python bindings')
source=("$url/archive/$pkgver/$pkgname-$pkgver.tar.gz" "gpgme-config.patch")
sha256sums=('4af9edb3219030d35f4972ce520444f7534bd9c94729456ec0aea76e868a103a'
            'b72de91a72209c37fd58edd76422d8aa862aceb3309ab7b70d1ac2f5fcbb503f')

prepare() {
  cd "$pkgname-$pkgver"
  # https://github.com/rpm-software-management/librepo/issues/269
  patch -Np1 -i ${srcdir}/gpgme-config.patch
}

build() {
  cd "$pkgname-$pkgver"

  cmake -B build \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_C_FLAGS_RELEASE='-DNDEBUG' \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_INSTALL_LIBDIR=lib \
        -DENABLE_DOCS=OFF \
        -DENABLE_PYTHON=ON \
            -DWITH_ZCHUNK=OFF

  make -C build
}

check() {
  cd "$pkgname-$pkgver"

  make -C build ARGS="-V" test
}

package() {
  cd "$pkgname-$pkgver"

  make -C build DESTDIR="$pkgdir/" install

  install -Dp -m644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}
